/*
 * Timer.h
 *
 *  Created on: 24.05.2011
 *      Author: aaw707
 */

#ifndef TIMER_H_
#define TIMER_H_

#include "HAL.h"
#include <signal.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/neutrino.h>
#include <hw/inout.h>
#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>


#define PORTS							0
#define TIMER							1

enum Timer_art {
 AMPEL_ROT_BLINK,
 PUCK_WEG_A0,
 PUCK_WEG_A1,
 PUCK_WEG_A2,
 PUCK_WEG_B0,
 PUCK_WEG_B1,
 PUCK_WEG_B2,
 PUCK_WEG_C0,
 PUCK_WEG_C1,
 PUCK_WEG_C2,
 ANFANG_VALID,
 HOEHE_VALID,
 METALL_VALID,
 WEICHE_VALID,
 RUTSCHE_VALID,
 AUSLAUF_VALID,
 PAUSE_PULSE,
 UNPAUSE_PULSE,
 LEER,
 LUECKE_VALID,
 PARTY
};

class Timer {
public:
	Timer(int, int, int, int, Timer_art);
	virtual ~Timer();
	long long Stoppen();
private:
	timer_t timerid;
	struct sigevent event;
	struct itimerspec timer;
	int timeSpanS_;
	int intervalS_;
	int timeSpanNS_;
	int intervalNS_;
	Timer_art timerArt_;

	void Starten();

	struct timeval zeit;
	long long start_time;
};

#endif /* TIMER_H_ */
